$(function() {
    let form = layui.form
    form.verify({
            pwd: [/^[\S]{6,12}$/],
            newPwd: function(value) {
                if ($(`[name=oldPwd]`).val() == value) {
                    return `新旧密码不能相同`
                }
            },
            rePwd: function(value) {
                if ($(`[name=newPwd]`).val() !== value) {
                    return `两次密码输入不一致`
                }
            }
        })
        //修改密码
    $(`#formPwd`).on(`submit`, function(e) {
        e.preventDefault()
        axios({
            method: `post`,
            url: `/my/updatepwd`,
            data: $(this).serialize()
        }).then(({ data: res }) => {
            if (res.status !== 0) {
                return layui.layer.msg(res.message)
            }
            console.log(`修改密码成功`);
            //重置表单
            $(`#formPwd`)[0].reset()
            setTimeout(() => {
                window.parent.location.href = `/login.html`
            }, 3000)
        })
    })
})